package com.example.kotlinstudy.bean

class Player4 {
    lateinit var equipment: String   //延迟初始化
    fun ready() {
        equipment = "sharp knife"
    }

    fun battle() {
//        lateinit 可以检查
        if (::equipment.isInitialized) println(equipment)
    }
}

class Player5(var name: String) {
    //延迟初始化
//    val config by lazy { loadConfig() } //惰性初始化

    val config = loadConfig()
    fun loadConfig(): String {
        println("loading ...")
        return "xxx"
    }
}

fun main() {
    /*val player4 = Player4()
//    player4.ready()
    player4.battle()*/
    val player5 = Player5("rose")
    println(player5.config)

}